package exception_3_11;

public class Logln {
    private static String userName = "admin";
    private static String password = "123456";

    public static void loglnInfo(String userName, String password)
            throws UserNameException, PasswordException{
        if(!Logln.userName.equals(userName)){
            throw new UserNameException("用户名错误！");
        }

        if(!Logln.password.equals(password)){
            throw new PasswordException("密码错误！");
        }

    }

    public static void main(String[] args) {
        try{
            loglnInfo("wsx", "252633");
        }catch (UserNameException e){
            System.out.println(e.getMessage());
            e.printStackTrace();
            System.out.println(e);
        }catch (PasswordException e){
            System.out.println(e);
        }
        System.out.println("登录成功！");
    }
}
//用户名异常类
class UserNameException extends Exception{
    public UserNameException(String message){
        super(message);
    }
}
//密码异常类
class PasswordException extends Exception{
    public PasswordException(String message){
        super(message);
    }
}
